package cn.tj212.xiaoyin.wechat.controller;

import cn.tj212.xiaoyin.common.page.TailPage;
import cn.tj212.xiaoyin.core.consts.CourseEnum;
import cn.tj212.xiaoyin.core.course.domain.Course;
import cn.tj212.xiaoyin.core.course.service.ICourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

/**
 * M站
 */
@Controller
@RequestMapping
public class IndexController {

    @Autowired
    private ICourseService courseService;

    //memcache客户端
    /*@Autowired
	MemcachedClient memcachedClient;*/

    @RequestMapping("/index")
    public ModelAndView index(TailPage<Course> page){
        ModelAndView mv=new ModelAndView("index");
        //只展示第一页课程
        Course queryEntity=new Course();
        queryEntity.setOnsale(CourseEnum.ONSALE.value());
        page.descSortField("weight");
        page=this.courseService.queryPage(queryEntity,page);
        mv.addObject("page",page);
        return mv;
    }
}
